#ifndef _MS2SIM_BLOCKCACHE_H_
#define _MS2SIM_BLOCKCACHE_H_

#include <clx/libECM.h>

typedef struct {
	ecm_uint32	id;
	ECMBOOL		valid;
	ecm_uint32	mid;
	ecm_uint32	bid;
	ecm_uint32	refcnt;
	ecm_uint32	length;
	ecm_ptr_t	priv;

	struct list_head	waiters;
} bcache_t;

typedef struct {
	const char *(*init)(ecm_uint32 cache_blksize, ecm_uint32 n_caches);
	void (*setup)(const sr_t *sr_mod_conf);
	void (*show_conf)(void);
	void (*add_media)(ecm_uint32 bid_max);

	void (*create)(bcache_t *);
	void (*hit)(bcache_t *);
	bcache_t *(*replace)(ecm_uint32 mid, ecm_uint32 bid);
	void (*put)(ecm_uint32 sid, bcache_t *);

	void (*access)(ecm_uint32 sid, ecm_uint32 mid, ecm_uint32 bid);
	void (*leave)(ecm_uint32 sid);
	void (*fini)(void);
} blockcache_op_t;

extern ecm_uint32 bc_get_inter_arrival_blks(ecm_uint32 mid);
extern bcache_t *bc_find_bcache(ecm_uint32 mid, ecm_uint32 bid);
extern void bc_printlog(const char *fmt, ...);

#endif
